let context = null
const initContext = (vue) => {
	context = vue;
}
//缓存工单信息 Type 1:插入更新缓存信息,2:查询缓存信息,
const CacheOrderInfoAsync = async (UserPhone,Type,WoId,WoInfo,token)=>{
	let IdentifyId = "CacheFinishOrder";
	var objects = {
		'PhoneNum':UserPhone,
		'WoId':WoId,
		'WoInfo':WoInfo,
		'type':Type
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		console.log(result);
		return result.data;
	}
	return null;
}

//现场图片上传接口
const WOPictureUploadInBatchAsync = async (UserPhone,ServiceOrderId,NewImages,token)=>{
	let IdentifyId = "WOPictureUploadInBatch";
	var objects = {
		'UserId':UserPhone,
		'ServiceOrderId':ServiceOrderId,
		'NewImages':NewImages,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

//现场图片删除接口
const WOPictureDeleteInBatchAsync = async (UserPhone,ServiceOrderId,DeletedImages,token)=>{
	let IdentifyId = "WOPictureDeleteInBatch";
	var objects = {
		'UserId':UserPhone,
		'ServiceOrderId':ServiceOrderId,
		'DeletedImages':DeletedImages,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

//现场图片获取接口
const WOPictureDetailsAsync = async (UserPhone,ServiceOrderId,token)=>{
	let IdentifyId = "WOPictureDetails";
	var objects = {
		'UserId':UserPhone,
		'ServiceOrderId':ServiceOrderId,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}
//完工页面=》确认产品
const ConfirmProductAsync = async (UserPhone,WoFinishType,Barcode,ProductId,WoObjectId,WoId,PurchaseDate,token)=>{
	let IdentifyId = "ConfirmProduct";
	var objects = {
		'UserId':UserPhone,
		'WoFinishType':WoFinishType,
		'Barcode':Barcode,
		'ProductId':ProductId,
		'WoObjectId':WoObjectId,
		'WoId':WoId,
		'PurchaseDate':PurchaseDate,
	};
	console.log(objects);
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

//完工页面=》验证物流码
const BarcodeValidCheckAsync = async (UserPhone,Barcode,token)=>{
	let IdentifyId = "BarcodeValidCheck";
	var objects = {
		'UserId':UserPhone,
		'Barcode':Barcode,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}
//提交完工
//WOTrans={}对象
//WOProducts=[]列表
const WOSubmitActionAsync = async (UserPhone, WOTrans={}, WOProducts=[],woCacheData, token) => {
	let IdentifyId = "WOSubmitAction";
	var objects = {
		'UserId': UserPhone,
		'WOTrans': WOTrans,
		'WOProducts': WOProducts,
		'CacheData':woCacheData,
	};
	let strObject = JSON.stringify(objects);
	let [error, result] = await context.commService.postEntityAsync(IdentifyId, strObject, token);
	if (!error && result.statusCode == 200) {
		return result.data;
	}
	return null;
}

//完工页面=》维修页面=》维修故障信息
const RepairFaultInfoListAsync = async (UserPhone,WOGuid,IdentifyName,FilterId,token)=>{
	let IdentifyId = "RepairFaultInfoList";
	var objects = {
		'UserId':UserPhone,
		'WOGuid':WOGuid,
		'IdentifyName':IdentifyName,
		'FilterId':FilterId,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

//完工页面=》获取产品信息
const ProductInfoAsync = async (UserPhone,ProductId,token)=>{
	let IdentifyId = "ProductInfo";
	var objects = {
		'UserId':UserPhone,
		'ProductId':ProductId,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

//完工页面=》维修页面=》故障件搜索旧件
const RepairSearchOldPartAsync = async (UserPhone,CustProductGuid,ProductGuid,CustProductPurchaseDate,IsCustProductConfirmed,PartsKeyWord,token)=>{
	let IdentifyId = "RepairSearchOldPart";
	var objects = {
		'UserId':UserPhone,
		'CustProductGuid':CustProductGuid,
		'ProductGuid':ProductGuid,
		'CustProductPurchaseDate':CustProductPurchaseDate,
		'IsCustProductConfirmed':IsCustProductConfirmed,
		'PartsKeyWord':PartsKeyWord,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

//完工页面=》维修页面=》故障件搜索新件
const RepairSearchNewPartAsync = async (UserPhone,CustProductGuid,ProductGuid,CustProductPurchaseDate,IsCustProductConfirmed,PartsKeyWord,WOGUID,token)=>{
	let IdentifyId = "RepairSearchNewPart";
	var objects = {
		'UserId':UserPhone,
		'CustProductGuid':CustProductGuid,
		'ProductGuid':ProductGuid,
		'CustProductPurchaseDate':CustProductPurchaseDate,
		'IsCustProductConfirmed':IsCustProductConfirmed,
		'PartsKeyWord':PartsKeyWord,
		'WOGUID':WOGUID,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

// 完工页面=》保养完工=》滤芯信息接口
const GetFilterInfoAsync = async (UserPhone,token)=>{
	let IdentifyId = "GetFilterInfo";
	var objects = {
		'UserId':UserPhone,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

//完工页面=》保养完工=》保养滤芯接口
// IsComfirmed Bool 类型
const GetPartsMaintainInfoAsync = async (UserPhone,PurchaseDate,CustEquipmentGuid,IsComfirmed,ProductGuid,token)=>{
	let IdentifyId = "GetPartsMaintainInfo";
	var objects = {
		'UserId':UserPhone,
		'PurchaseDate':PurchaseDate,
		'CustEquipmentGuid':CustEquipmentGuid,
		'IsComfirmed':IsComfirmed,
		'ProductGuid':ProductGuid,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

//完工页面=》维修页面=》保内转保外原因代码
const ExcludeFromWarrantyReasonCodeListAsync = async (UserPhone,token)=>{
	let IdentifyId = "ExcludeFromWarrantyReasonCodeList";
	var objects = {
		'UserId':UserPhone,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

// 完工页面=》维修页面=》保外转保内的原因代码
const ApplySpecialWarrantyReasonCodeListAsync = async (UserPhone,token)=>{
	let IdentifyId = "ApplySpecialWarrantyReasonCodeList";
	var objects = {
		'UserId':UserPhone,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}
//根据保养编号获取保养信息
const GetMaintainPartInfoByPartNum = async(UserPhone,KeyWords,WOGUID,token)=>{
	let IdentifyId = "ReplaceFilterByPartsNum";
	let objects = {
		'UserId':UserPhone,
		'KeyWords':KeyWords,
		'WOGUID':WOGUID,
	};
	let strObject = JSON.stringify(objects);
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}
//获取滤芯列表
const GetMaintainPartListByPartNum = async(UserPhone,KeyWords,WOGUID,token)=>{
	let IdentifyId = "ReplaceFilterByKeyWord";
	let objects = {
		'UserId':UserPhone,
		'KeyWords':KeyWords,
		'WOGUID':WOGUID,
	};
	let strObject = JSON.stringify(objects);
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

//完工页面=》地址列表（省或市或区）
const AddressListAsync = async (UserPhone,IdentifyName,FilterId,token)=>{
	let IdentifyId = "AddressList";
	var objects = {
		'UserId':UserPhone,
		'IdentifyName':IdentifyName,
		'FilterId':FilterId,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

const workordercompleteservice={
	initContext,
	CacheOrderInfoAsync,
	WOPictureUploadInBatchAsync,
	WOPictureDeleteInBatchAsync,
	WOPictureDetailsAsync,
	ConfirmProductAsync,
	BarcodeValidCheckAsync,
	WOSubmitActionAsync,
	RepairFaultInfoListAsync,
	ProductInfoAsync,
	RepairSearchOldPartAsync,
	RepairSearchNewPartAsync,
	GetFilterInfoAsync,
	GetPartsMaintainInfoAsync,
	ExcludeFromWarrantyReasonCodeListAsync,
	ApplySpecialWarrantyReasonCodeListAsync,
	GetMaintainPartInfoByPartNum,
	GetMaintainPartListByPartNum,
	AddressListAsync,
}

export default workordercompleteservice;